<?php

namespace app\common\model\xilujob;

use think\Model;

class UserBlacklistCompany extends Model
{
    protected $name = 'xilujob_user_blacklist_company';

    protected $autoWriteTimestamp = 'int';


    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    /**
     * 获取用户拉黑的企业列表
     * @param $userId
     * @return false|\PDOStatement|string|\think\Collection
     */
    public static function getBlacklist($userId) {
        $query = new EnterpriseInfo();
        $list = $query->alias('ei')->join('XilujobUserBlacklistCompany b', 'ei.company_id=b.company_id')
            ->where('b.user_id','=', $userId)
            ->field('ei.company_id as id,company_name')
            ->select();
        return $list;
    }

    /**
     * 获取用户拉黑的企业的id数组
     * @param $userId
     * @return array
     */
    public static function getBlackCompanyIds($userId) {
        return static::where('user_id', $userId)->column('company_id');
    }

}
